from copy import deepcopy as copy


def attribute_control_copy(control):
    _control = {}
    for k,v in control.iteritems():
        if k in ['callback']:
            _control[k] = v
        else:
            _control[k] = copy(v)
    return _control


def attribute_panel_copy(panel):
    _panel = {}
    for k,v in panel.iteritems():
        if k == 'controls':
            _panel['controls'] = []
            for column in v:
                _panel['controls'].append([])
                for control in column:
                    _panel['controls'][-1].append(attribute_control_copy(control))
        else:
            _panel[k] = copy(v)
    return _panel

